package indi.jp.project.business.jingying.controller;

import indi.jp.project.business.jingying.pojo.po.ActivityPlanPO;
import indi.jp.project.business.jingying.pojo.query.ActivityPlanQuery;
import indi.jp.project.business.jingying.service.ActivityPlanService;
import indi.jp.project.core.entity.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 经营活动策划
 *
 * @author jiangping
 * @date 2022/5/10
 */
@RestController
@RequestMapping("/jingying/activity/plan")
public class ActivityPlanController {

    @Resource
    private ActivityPlanService activityPlanService;

    @GetMapping("/grid")
    public JsonResult queryGrid(ActivityPlanQuery query) throws Exception {
        return activityPlanService.queryGrid(query);
    }

    @PostMapping("/save")
    public JsonResult save(@RequestBody ActivityPlanPO activityPlanPO, HttpServletRequest request) throws Exception {
        String account = request.getParameter("account");
        activityPlanPO.setCreateBy(account);
        activityPlanPO.setModifyBy(account);
        return activityPlanService.save(activityPlanPO);
    }

    @GetMapping("/findById")
    public JsonResult findById(@RequestParam String id) throws Exception {
        return activityPlanService.findById(id);
    }

    @PostMapping("/deleteById")
    public JsonResult deleteById(@RequestParam String id, HttpServletRequest request) throws Exception {
        return activityPlanService.deleteById(id);
    }

}
